class t{constructor(){this.eventMap=new Map}on(t,e,n){this._on(t,e,n,!1)}once(t,e,n){this._on(t,e,n,!0)}_on(t,e,n,l){let a=this.eventMap.get(t);null==a&&(a=[],this.eventMap.set(t,a)),a.push({callback:e,target:n,once:l})}off(t,e,n){const l=this.eventMap.get(t);if(null==l)return!1;const a=l.findIndex((t=>t.callback==e&&t.target==n));if(-1==a)return!1;l.removeAt(a)}offType(t){const e=this.eventMap.get(t);null!=e&&(e.length=0)}offAll(){this.eventMap.clear()}dispatch(t,...e){const n=this.eventMap.get(t);if(null!=n)for(let t=n.length-1;t>=0;t--){const l=n[t];l.callback.call(l.target,...e),l.once&&n.splice(t,1)}}hasListener(t,e,n){const l=this.eventMap.get(t);if(null==l)return!1;return-1!=l.findIndex((t=>t.callback==e&&t.target==n))}}export{t as default};
